package org.visionlibrary.image.filters.morphology;

import java.awt.Point;

import javax.media.jai.TiledImage;

import org.visionlibrary.image.model.WindowFilter;


public class Dilatate extends WindowFilter {	
	@Override
	protected int getNewPixelVal(TiledImage src, Point p, int channel) throws NullPointerException {
		if(src.getSample(actualPixel.x, actualPixel.y, channel) == 255)
			return 255;
		
		boolean res = true;
		Point pIter = new Point();
		for (pIter.y = 0; pIter.y < windowHeight; pIter.y++)
			for (pIter.x = 0; pIter.x < windowWidth; pIter.x++) {
				res = res && (getWindowPixelVal(src, pIter, channel) != 255);
			}
		if(res)
			return 0;
		else
			return 255;
	}

	@Override
	protected void setWindowProperties() {
		this.windowHeight = 3;
		this.windowWidth = 3;
		this.dstPointInWindow = new Point(1,1);
	}
}